/**
 * 与商品相关的接口
 */
import { get, post } from "../request"

const commodity = {
    // 获取商品信息
    getCommodity(commodityId) {
        return get(
            `/commodity/info/${commodityId}`
        )
    },

    // 获取所有商品信息
    getCommodityList(param) {
        return get(
            '/commodity/info',
            param
        )
    },

    // 获取商店的商品
    getCommodityFromStore(storeId, param) {
        return get(
            `/commodity/store/${storeId}`,
            param,
        )
    },

    // 获取所有的商品上架申请
    getLaunchRequest(param) {
        return get(
            '/commodity/launch-request',
            param,
        )
    },

    // 获取所有的商品修改申请
    getModifyRequest(param) {
        return get(
            '/commodity/modify-request',
            param,
        )
    },

    // 获取商店的所有商品上架申请
    getLaunchRequestFromStore(storeId, param) {
        return get(
            `/commodity/launch-request/store/${storeId}`,
            param
        )
    },

    // 获取商店的所有修改商品信息申请
    getModifyRequestFromStore(storeId, param) {
        return get(
            `/commodity/modify-request/store/${storeId}`,
            param,
        )
    },

    // 获取所有正在参加特定活动的商品
    getActivityCommodity(activityId, param) {
        return get(
            `/commodity/activity/${activityId}`,
            param
        )
    },

    // 发起商品上架申请
    applyLaunchRequest(param) {
        return post(
            '/commodity/launch-request',
            param
        )
    },

    // 发起商品修改信息申请
    applyModifyRequest(param) {
        return post(
            '/commodity/modify-request',
            param,
        )
    },

    // 发起商品下架
    commodityOffShelf(commodityId) {
        return post(
            `/commodity/off-shelf/${commodityId}`
        )
    },

    // 处理商品上架申请
    processLaunchRequest(param) {
        return post(
            '/commodity/launch-request/process',
            param,
        )
    },

    // 处理商品修改信息申请
    processModifyRequest(param) {
        return post(
            '/commodity/modify-request/process',
            param,
        )
    }
}

export default commodity;